import {
  getUserInfoApi
} from "@/api/layout"

// 定义用户 子模块
const userModule = {
  namespaced: true,
  state() {
    return {
      token: '',
      userInfo: {}
    }
  },
  mutations: {
    setToken(state, tokenStr) {
      state.token = tokenStr
    },
    setUserInfo(state, userObj) {
      state.userInfo = userObj
    }
  },
  actions: {
    async getUserAction(store) {
      const {
        data: {
          data: userObj
        }
      } = await getUserInfoApi()
      store.commit('setUserInfo', userObj)
    }
  }
}

// 导出用户 子模块
export default userModule
